<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = ["twj", "wdf", "jjb"]
        for (const a of arr) {
            console.log(a)
        }
        console.log(arr)
        //arr数组原型中封装了Symbol(Symbol.iterator)属性，也称遍历器接口
        let iter = arr[Symbol.iterator]() //得到遍历器对象
        console.log(iter)
        console.log(iter.next()) //{value: 'twj', done: false}
        console.log(iter.next()) //{value: 'wdf', done: false}
        console.log(iter.next()) //{value: 'jjb', done: false}
        console.log(iter.next()) //{value: 'undefined', done: none}

        //字符串也能使用for..of进行遍历，因为它也封装了遍历器接口
        let str = "twjnbnb"
        for (const s of str) {
            console.log(s)
        }

        //arguments也封装了遍历器接口
        function test() {
            for (let arg of arguments) {
                console.log(arg)
            }
        }
        test(1, 2, 3, 4)
    </script>
</body>

</html>